﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SeaBattle.Domain.Abstract.Services;
using SeaBattle.Domain.Entities;
using SeaBattle.Domain.Abstract;

namespace SeaBattle.Domain.Concrete.Services
{
    public class FakeGameService : IGameService
    {
        private IPlayerService playerService;
        private IGameRepository gameRepository;

        public FakeGameService(IPlayerService playerService, IGameRepository gameRepository)
        {
            this.playerService = playerService;
            this.gameRepository = gameRepository; 
        }

        public IEnumerable<Game> GetOpenedGames()
        {
            return from x in gameRepository.GetAllGames()
                   where x.Opened
                   orderby x.Preset
                   select x;
        }

        public IEnumerable<Game> GetParticipantsPlayerGames(Player player)
        {
            return from x in gameRepository.GetAllGames()
                   where x.Creator == player || x.Opponent == player
                   orderby x.Created descending
                   select x;
        }
    }
}
